Copyright ã1995 by NeXT Computer, Inc.  All Rights Reserved.

IXStoreBlock

Inherits From:	Object

Conforms To:	IXBlockAndStoreAccess
NXReference

Declared In:	store/IXStoreBlock.h

Class Description

An IXStoreBlock manages a single block within an IXStore, supporting access methods similar to those of IXStore and permitting multiple references to the same block.  It also implements methods for archiving and unarchiving an object in its block of storage.  You can use this class as a convenient means of manipulating blocks of storage without needing to know the id of the associated IXStore, and for storing NEXTSTEP objects in an IXStore.

This class is intended primarily as a means of associating a name with a block in an IXStoreDirectory.  To associate names with large numbers of nonobject values, use an IXBTree.  To archive large numbers of objects, use IXRecordManager.

Instance Variables

IXStore *store;

unsigned int handle;

unsigned int blockSize;

store	The IXStore that the block resides in.

handle	The block handle.

blockSize	The size of the block.

Adopted Protocols

IXBlockAndStoreAccess 	- initInStore:
- initFromBlock:inStore:
- freeFromStore
+ freeFromBlock:inStore:
- getBlock:andStore:

NXReference	- addReference
- free
- references

Method Types

Accessing the block's contents	- openAtOffset:forLength:
- readAtOffset:forLength:
- copyAtOffset:forLength:
- close

Managing the block size	- resizeTo:
- size

Archiving an object in an IXStoreBlock
- readObject
- writeObject:

Instance Methods

close

- close

Closes the block of storage managed by the IXStoreBlock.  To destroy the block of storage, send a freeFromBlock:inStore: message to the IXStoreBlock (this will also free the IXStoreBlock).  Returns the IXStore containing the block.

This method doesn't affect transactions in any way.  If you want to make the block available to other contexts, you should send commitTransaction to the IXStore.

copyAtOffset:forLength:

- (unsigned int)copyAtOffset:(unsigned int)anOffset forLength:(unsigned int)aLength

Copies a portion of the IXStoreBlock's block, creating a new block.  The copy is made from the section of the block beginning at anOffset within the block, of aLength bytes.  Returns the handle of the copy.

See also:  - copyBlock:atOffset:forLength: (IXStore)

openAtOffset:forLength:

- (void *)openAtOffset:(unsigned int)anOffset forLength:(unsigned int)aLength

Returns a pointer to the portion of the IXStoreBlock's block specfied by anOffset, of aLength bytes, after having the IXStore open it for writing.  If your code writes outside of the specified area, the IXStore's contents may be corrupted.

Note:  Unless it's certain that the IXStoreBlock's store is memory-based, your application should assume that the data in the block is big-endian, and convert it to and from host endian-ness as needed.

See also:  - readAtOffset:forLength:, - openBlock:atOffset:forLength: (IXStore), - readBlock:atOffset:forLength: (IXStore)

readAtOffset:forLength:

- (void *)readAtOffset:(unsigned int)anOffset forLength:(unsigned int)aLength

Returns a pointer to the portion of the IXStoreBlock's block specfied by anOffset, of aLength bytes, after having the IXStore open it for reading.  If you write to the block, the IXStore's contents may be corrupted

Note:  Unless it's certain that the IXStoreBlock's store is memory-based, your application should assume that the data in the block is big-endian, and convert it to host endian-ness as needed.

See also:  - openAtOffset:forLength:, - openBlock:atOffset:forLength: (IXStore), - readBlock:atOffset:forLength: (IXStore)

readObject

- readObject

Unarchives and returns the object that was previously archived in the IXStoreBlock's block.  The archived object must implement the read: method in order to be unarchived.

See also:  - writeObject:, - read: (Object), - write: (Object)

resizeTo:

- resizeTo:(unsigned int)size

Resizes the IXStoreBlock's block to be size bytes long, and returns self.  The block can only be resized when it's not open.

See also:  - size, - resizeBlock:ToSize: (IXStore), - sizeOfBlock: (IXStore)

size

- (unsigned int)size

Returns the size of the IXStoreBlock's block, in bytes.

See also:  - resizeToSize:, - sizeOfBlock: (IXStore), - resizeBlock:ToSize: (IXStore)

writeObject:

- writeObject:(unsigned int)anObject

Archives anObject into the IXStoreBlock's block.  anObject must implement the write: method in order to be archived.  The block is resized to fit the archived object if necessary.  Returns self.

See also:  - readObject, - write: (Object), - read: (Object)